package com.ilxqx.framework.system.service.impl;

import com.ilxqx.framework.system.entity.SysPermission;
import com.ilxqx.framework.system.form.search.SysPermissionSearchForm;
import com.ilxqx.framework.system.repository.SysPermissionRepository;
import com.ilxqx.framework.system.service.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 系统权限服务实现类
 * @author venus
 */
@Service
public class SysPermissionServiceImpl extends AbstractSearchableServiceImpl<SysPermission, Long, SysPermissionSearchForm> implements SysPermissionService {

	private final SysPermissionRepository sysPermissionRepository;

	@Autowired
	public SysPermissionServiceImpl(SysPermissionRepository sysPermissionRepository) {
		super(sysPermissionRepository);
		this.sysPermissionRepository = sysPermissionRepository;
	}

	/**
	 * 创建空的或者带有默认值的实体对象
	 *
	 * @return 实体对象
	 */
	@Override
	public SysPermission create() {
		return new SysPermission();
	}

	/**
	 * 根据父级权限ID，查找所有子权限
	 *
	 * @param parentPermissionId 父级权限ID
	 * @return 子权限列表
	 */
	@Override
	public List<SysPermission> getListByParentPermissionId(long parentPermissionId) {
		return this.sysPermissionRepository.getAllByParentPermissionId(parentPermissionId);
	}

}
